package com.hejjon.core.enumer;

import lombok.Getter;

@Getter
public enum BasicTypeEnum {

    STRING("String", "字符串", "VARCHAR"),
    LONG_TEXT("LongText", "长文本", "LONGTEXT"),
    DATE("Date", "日期", "DATETIME"),
    INT("Int", "整数", "INT"),
    DATE_TIME("DateTime", "日期时间", "DATETIME"),
    DOUBLE("Double", "小数", "DOUBLE");
    ;

    private final String code;

    private final String desc;

    private final String jdbcType;


    BasicTypeEnum(String code, String desc, String jdbcType) {
        this.code = code;
        this.desc = desc;
        this.jdbcType = jdbcType;
    }

    /**
     * 根据code获取枚举实例
     */
    public static BasicTypeEnum getByCode(String code) {
        for (BasicTypeEnum typeEnum : values()) {
            if (typeEnum.code.equals(code)) {
                return typeEnum;
            }
        }
        return STRING;
    }

}
